package com.qf.controller;

import com.qf.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/8 16:37
 */
@Controller
@RequestMapping("/json")
public class jsonController {
    /**
     * 跳转
     * @return
     */
    @RequestMapping("toJsp")
    public String toJosnJsp(){
        System.out.println("跳转");
        return "jsonDemo";
    }


    /**
     * @RequestBody注解可以将接收到的json格式字符串自动转换成java对象
     * @ResponseBody 注解可以将controller方法的返回值自动转换成json格式字符串返回
     * @param user
     */
    @RequestMapping("/test1")
    @ResponseBody
    public User test1(@RequestBody User user){

        System.out.println(user);
        return user;
    }

}
